<template>
  <div class="common-page f-c">
    <BackPage title="会商会审" />
    <div class="search-params f-r a-c j-b">
      <el-form inline>
        <el-form-item label="项目名称：">
          <el-input clearable v-model="searchParams.projectName" />
        </el-form-item>
        <el-form-item label="会议状态：">
          <el-select clearable v-model="searchParams.status">
            <el-option v-for="item in options" :key="item.value" :value="item.value" :label="item.name" />
          </el-select>
        </el-form-item>
        <el-form-item label="发起人：">
          <el-input clearable v-model="searchParams.realname" />
        </el-form-item>
        <el-form-item label="开始时间：">
          <el-date-picker
            v-model="searchParams.timeValue"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" round @click="onSearch">筛选</el-button>
          <el-button round @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="table-box f-g">
      <el-table
        height="100%"
        v-loading="loading"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column type="index" width="80px" label="序号" align="center" />
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="会议状态" width="100px">
          <template slot-scope="scope">
            <el-button type="text" :style="{color: scope.row.statusColor }">{{ scope.row.statusName}}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="100px">
          <template slot-scope="scope">
            <el-button type="text" @click="onRead(scope.row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <Detail ref="DetailRef" />
  </div>
</template>

<script>
import crud from '@/mixins/crud'
import Detail from './detail'
import { http_audit } from '@/api'
export default {
  name: 'Index',
  components: {
    Detail
  },
  mixins: [crud],
  data() {
    return {
      request: http_audit,
      searchParams: {
        projectName: '',
        timeValue: [],
        realname: '',
        status: ''
      },
      options: [
        { value: 0, name: '待开始', color: '#EC2727' },
        { value: 1, name: '进行中', color: '#ECB32C' },
        { value: 2, name: '已完成', color: '#27BE1C' }
      ],
      columns: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'startTime', label: '开始时间' },
        { prop: 'endTime', label: '结束时间' },
        { prop: 'realName', label: '发起人' },
        { prop: 'reason', label: '发起原因' }
      ],
      tableData: [
      ]
    }
  },
  methods: {
    formatTableData(data) {
      data.forEach(el => {
        el.statusName = this.options.find(item => item.value == el.status)?.name
        el.statusColor = this.options.find(item => item.value == el.status)?.color
      })
    },
    onRead(item) {
      this.$refs.DetailRef.open(item)
    }
  }
}
</script>

<style scoped lang="scss">
</style>
